package com.atguigu.flink.sqlfunction;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.catalog.hive.HiveCatalog;

/**
 * Created by Smexy on 2023/2/6
 *
 *      Catalog: 元数据目录。
 *              读取hive中的元数据，需要通过元数据服务去读取！
 *                  启动 hive metastore service
 */
public class Demo7_HiveCatelog
{
    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        StreamTableEnvironment tableEnvironment = StreamTableEnvironment.create(env);

        //创建hivecatalog
        HiveCatalog hiveCatalog = new HiveCatalog("hive", "gmall", "data/conf");
        //注册
        tableEnvironment.registerCatalog("hivecatalog",hiveCatalog);
        //当前要使用hiveCatalog  取注册的名字
        tableEnvironment.useCatalog("hivecatalog");

        tableEnvironment.sqlQuery("select * from ods_log_inc limit 1")
                        .execute().print();

    }
}
